package com.ldatum.crm.serviceImpl;

import java.util.List;

import com.ldatum.crm.dao.InventoryDao;
import com.ldatum.crm.dao.SellerdetailDao;
import com.ldatum.crm.daoImpl.InventoryDaoImpl;
import com.ldatum.crm.daoImpl.SellerdetailDaoImpl;
import com.ldatum.crm.domain.Sellerdetail;
import com.ldatum.crm.service.SellerdetailService;

public class SellerdetailServiceImpl implements SellerdetailService {
	SellerdetailDao sellerdetailDao = new SellerdetailDaoImpl();
	InventoryDao inventoryDao = new InventoryDaoImpl();
	@Override
	public int saveSellerDetail(List<Sellerdetail> sellerDetailList)
			throws Exception {
		boolean b ;
		for(Sellerdetail sd:sellerDetailList){
			b = inventoryDao.validationNo(sd.getYpbm());
			if(b){
				inventoryDao.updateOfSubtraction(sd);
			}else{
			}
		}
		return sellerdetailDao.saveSellerDetail(sellerDetailList);
	}
	@Override
	public List<Sellerdetail> findByDjh(String djh) throws Exception {
		return sellerdetailDao.findByDjh(djh);
	}
	@Override
	public List<Sellerdetail> list() throws Exception {
		return sellerdetailDao.list();
	}

}
